furny.furndb.importer
Class FilePathModelSource

java.lang.Object
  extended by furny.furndb.importer.FilePathModelSource
All Implemented Interfaces:
IModelSource

public class FilePathModelSource
extends java.lang.Object
implements IModelSource

Implementation of a model source that iterates over all files from a given path.

Since:
26.06.2011
Author:
stephan

Field Summary
private static java.lang.String ASSET_PREFIX
           
private  java.lang.String assetPath
           
private  java.util.List<java.io.File> files
           
private  int index
           
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
FilePathModelSource(java.lang.String assetPath)
          Creates a new model source, where all files of the given path will be iterated.
 
Method Summary
 int getSize()
          Returns the number of elements.
 boolean hasNext()
          Method to check if more elements are there.
 Furniture next()
          Gets the next element.
 Furniture next(int offset)
          This methods works like next(), but allows to skip elements.
 Furniture previous()
          Gets the previous element.
 void reset()
          Resets and starts at the first element.
 void seek(Furniture furn)
          Seeks the given furniture and remembers its position.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

ASSET_PREFIX

private static final java.lang.String ASSET_PREFIX
See Also:
Constant Field Values

assetPath

private final java.lang.String assetPath

files

private java.util.List<java.io.File> files

index

private int index
Constructor Detail

FilePathModelSource

public FilePathModelSource(java.lang.String assetPath)
Creates a new model source, where all files of the given path will be iterated.

Parameters:
assetPath - The path of the files to iterate
Since:
26.06.2011
Method Detail

reset

public void reset()
Description copied from interface: IModelSource
Resets and starts at the first element.

Specified by:
reset in interface IModelSource

seek

public void seek(Furniture furn)
Description copied from interface: IModelSource
Seeks the given furniture and remembers its position. A call to next() will give the element after the seeked element.

Specified by:
seek in interface IModelSource
Parameters:
furn - The furniture to seek

hasNext

public boolean hasNext()
Description copied from interface: IModelSource
Method to check if more elements are there.

Specified by:
hasNext in interface IModelSource
Returns:
more elements are left

next

public Furniture next(int offset)
Description copied from interface: IModelSource
This methods works like next(), but allows to skip elements. If the offset is negative, it will return previous elements.

The method works circular, when hasNext() returns false, and the last element is reached, a call to next() will start at the first element.

Specified by:
next in interface IModelSource
Parameters:
offset - The offset of elements
Returns:
the furniture at the desired position

next

public Furniture next()
Description copied from interface: IModelSource
Gets the next element. It simply calls next(1).

Specified by:
next in interface IModelSource
Returns:
the next furniture

previous

public Furniture previous()
Description copied from interface: IModelSource
Gets the previous element. It simply calls next(-1).

Specified by:
previous in interface IModelSource
Returns:
the previous furniture.

getSize

public int getSize()
Description copied from interface: IModelSource
Returns the number of elements.

Specified by:
getSize in interface IModelSource
Returns:
the number of elements.